<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学校注册页面</title>
    <link rel="stylesheet" href="../css/register_sch.css">
    <script src="../js/vue.js"></script>
    <script src="../js/axios.min.js"></script>
</head>

<body>
    <div class="header">
        <div class="logo"><a href="index.html" target="_blank"><img src="../images/logo.png" alt="logo"></a></div>
    </div>
    <div class="content" id="app">
        <form action="">
            <table class="con-table">
                <thead class="con-th">
                    <tr>
                        <th colspan="2">学校注册页面</th>
                    </tr>
                </thead>
                <tbody con-tb>
                    <tr>
                        <td><i>*</i>账户地址</td>
                        <td><input type="text" v-model="sch_info.schoolaccount"></td>
                    </tr>
                    <tr>
                        <td><i>*</i>校长名称</td>
                        <td><input type="text" v-model="sch_info.headmastername"></td>
                    </tr>
                    <tr>
                        <td><i>*</i>学校编号</td>
                        <td><input type="text" v-model="sch_info.schoolid"></td>
                    </tr>
                    <tr>
                        <td><i>*</i>学校名称</td>
                        <td><input type="text" v-model="sch_info.schoolname"></td>
                    </tr>
                    <tr class="btn">
                        <td colspan="2" class="submit"><button type="button" @click="submit">注册</button></td>
                    </tr>
                </tbody>


            </table>
        </form>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                sch_info: {
                    schoolaccount: '',
                    schoolname: '',
                    schoolid: '',
                    headmastername: ''
                },
            },
            methods: {
                submit() {
                    if (this.sch_info.schoolaccount && this.sch_info.schoolname && this.sch_info.schoolid && this.sch_info.headmastername) {
                        console.log(this.sch_info);
                        axios.post("http://localhost:80/schoolregister", this.sch_info).then(response => {
                            if (response.data.code == 200) {
                                alert("添加成功")
                            } else {
                                alert("添加失败")
                            }
                        })
                    } else {
                        alert("您还有未填写的必要信息！");
                    }

                }
            }
        })
    </script>
</body>

</html>